ActionController::Routing::Routes.draw do |map|

  # Add your own custom routes here.
  # The priority is based upon order of creation: first created -> highest priority.
  
  # Connect the root to the herbarium controller.
  map.connect '', :controller => "herbarium", :action => "index"

  # Avoid conflicts with riki's search route.
  map.search   'herbarium/search', :controller => "herbarium", :action => "search"
 
  # Allow downloading Web Service WSDL as a file with an extension
  # instead of a file named 'wsdl'
  map.connect ':controller/service.wsdl', :action => 'wsdl'

  map.connect  'riki_admin', :controller => 'riki_admin', :action => "index"
  map.connect  'books', :controller => 'books', :action => "index"
  map.connect  'user/:action/:id', :controller => 'user'
  map.connect  'role/:action/:id', :controller => 'role'
  map.connect  '', :controller => "books", :action => "premiere"

  map.home     ':book_url_name', :controller => "pages", :action => "show", :page_title => "Home Page"
  map.pages    ':book_url_name/pages', :controller => "pages", :action => "index"
  map.recent   ':book_url_name/recent', :controller => "pages", :action => "recent"
  map.page     ':book_url_name/pages/:page_title', :controller => "pages", :action => "show"
  #map.page     ':book_url_name/pages/:page_title', :controller => "pages", :action => "analyse_page"
  map.new      ':book_url_name/pages/:page_title/versions/new', :controller => "versions", :action => "new"
  map.rollback ':book_url_name/pages/:page_title/versions/new/:version_number', :controller => "versions", :action => "new", :requirements => { :version_number => /^\d+$/ }
  map.version  ':book_url_name/pages/:page_title/versions/:version_number', :controller => "versions", :action => "show", :requirements => { :version_number => /^\d+$/ }
  map.import   ':book_url_name/import', :controller => "books", :action => "import"
  map.analyze  ':book_url_name/analyze', :controller => "books", :action => "analyze"
  map.clean_cache ':book_url_name/clean_cache', :controller => "books", :action => "clean_cache"
  map.login    ':book_url_name/login', :controller => "books", :action => "login"
  map.logout   ':book_url_name/logout', :controller => "books", :action => "logout"
  map.users    ':book_url_name/users', :controller => "books", :action => "users"
  map.search   ':book_url_name/search', :controller => "books", :action => "search"
  
    
  map.connect  ':book_url_name/pages/:page_title/:controller/:action/:id'

  map.feed     ':book_url_name/feed.rss', :controller => "books", :action => "feed"

  map.connect  ':book_url_name/:controller/:action/:id'

  # Install the default route as the lowest priority.
  map.connect ':controller/:action/:id'

end
